package com.haoqizhe.kernel.activemq.template;

import com.haoqizhe.kernel.activemq.connection.ActiveMQConnectionFactoryConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.*;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;


/**
 * @author  haoqizhe.li on 2017/6/12.
 *
 * 自定义jmsTemplate 支持事务管理
 */
@Configuration
@DependsOn(value = "cachingConnectionFactory")
@Import({ActiveMQConnectionFactoryConfiguration.class})
public class JmsTemplateConfig {

    @Autowired
    private CachingConnectionFactory cachingConnectionFactory;


    @Bean(name = "defaultJmsTemplate")
    public JmsTemplate getJmsTemplate(){
        return new JmsTemplate(cachingConnectionFactory);
    }

}
